package com.netease.pris.c;

import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import com.netease.b.a.d;
import com.netease.pris.protocol.c;
import com.netease.pris.provider.q;

public class h
{
  static String[] a;
  public static final int b = 0;
  public static final int c = 1;
  public static final int d = 2;
  public static final int e = 3;
  public static final int f = 4;
  public static final int g = 5;
  public static final int h = 6;
  public static final int i = 7;

  static
  {
    String[] arrayOfString = new String[8];
    arrayOfString[0] = "_id";
    arrayOfString[1] = "name";
    arrayOfString[2] = "password";
    arrayOfString[3] = "last_login";
    arrayOfString[4] = "auot_login";
    arrayOfString[5] = "main";
    arrayOfString[6] = "other";
    arrayOfString[7] = "first_login";
    a = arrayOfString;
  }

  public static long a(Context paramContext, String paramString)
  {
    long l1 = 0L;
    Cursor localCursor;
    long l2;
    if ((paramContext != null) && (paramString != null))
    {
      ContentResolver localContentResolver = paramContext.getContentResolver();
      Uri localUri = q.j;
      String[] arrayOfString1 = new String[1];
      arrayOfString1[0] = "refresh";
      String[] arrayOfString2 = new String[1];
      arrayOfString2[0] = paramString;
      localCursor = localContentResolver.query(localUri, arrayOfString1, "name =?", arrayOfString2, null);
      if (localCursor != null)
      {
        if (!localCursor.moveToFirst())
          break label97;
        l2 = localCursor.getLong(0);
      }
    }
    while (true)
    {
      localCursor.close();
      l1 = l2;
      return l1;
      label97: l2 = l1;
    }
  }

  public static Cursor a(Context paramContext)
  {
    Cursor localCursor = null;
    if (paramContext == null);
    while (true)
    {
      return localCursor;
      String str = "main = " + q.o;
      localCursor = paramContext.getContentResolver().query(q.j, a, str, null, null);
    }
  }

  public static void a(Context paramContext, String paramString, long paramLong)
  {
    if ((paramContext != null) && (paramString != null))
    {
      if (!c.b.equals(paramString))
        break label31;
      a(paramContext, c.b, c.b, paramLong);
    }
    while (true)
    {
      return;
      label31: ContentValues localContentValues = new ContentValues();
      localContentValues.put("refresh", Long.valueOf(paramLong));
      ContentResolver localContentResolver = paramContext.getContentResolver();
      Uri localUri = q.j;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = paramString;
      localContentResolver.update(localUri, localContentValues, "name =?", arrayOfString);
    }
  }

  public static void a(Context paramContext, String paramString, boolean paramBoolean)
  {
    if ((TextUtils.isEmpty(paramString)) || (paramContext == null))
      return;
    String str = "name = '" + paramString + "' ";
    ContentValues localContentValues = new ContentValues();
    if (paramBoolean);
    for (int j = 0; ; j = 1)
    {
      localContentValues.put("first_login", Integer.valueOf(j));
      paramContext.getContentResolver().update(q.j, localContentValues, str, null);
      break;
    }
  }

  public static boolean a(Context paramContext, String paramString1, String paramString2)
  {
    return a(paramContext, paramString1, paramString2, 0L);
  }

  public static boolean a(Context paramContext, String paramString1, String paramString2, long paramLong)
  {
    int j = 1;
    if ((TextUtils.isEmpty(paramString1)) || (TextUtils.isEmpty(paramString2)))
      j = 0;
    while (true)
    {
      return j;
      if (f(paramContext, paramString1))
      {
        ContentValues localContentValues1 = new ContentValues();
        localContentValues1.put("name", paramString1);
        localContentValues1.put("password", paramString2);
        if (paramLong > 0L)
          localContentValues1.put("refresh", Long.valueOf(paramLong));
        ContentResolver localContentResolver = paramContext.getContentResolver();
        Uri localUri1 = q.j;
        String[] arrayOfString = new String[j];
        arrayOfString[0] = paramString1;
        if (localContentResolver.update(localUri1, localContentValues1, "name =?", arrayOfString) > 0)
          continue;
        j = 0;
        continue;
      }
      ContentValues localContentValues2 = new ContentValues();
      localContentValues2.put("name", paramString1);
      localContentValues2.put("password", paramString2);
      if (paramLong > 0L)
        localContentValues2.put("refresh", Long.valueOf(paramLong));
      Uri localUri2 = paramContext.getContentResolver().insert(q.j, localContentValues2);
      if (localUri2 != null);
      try
      {
        long l = ContentUris.parseId(localUri2);
        if (l >= 0L)
          continue;
        j = 0;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        j = 0;
      }
    }
  }

  public static void b(Context paramContext)
  {
    if (paramContext == null);
    while (true)
    {
      return;
      paramContext.getContentResolver().delete(q.j, null, null);
    }
  }

  public static void b(Context paramContext, String paramString)
  {
    if ((TextUtils.isEmpty(paramString)) || (paramContext == null));
    while (true)
    {
      return;
      String str1 = "main = " + q.o;
      ContentValues localContentValues1 = new ContentValues();
      localContentValues1.put("main", Integer.valueOf(q.p));
      paramContext.getContentResolver().update(q.j, localContentValues1, str1, null);
      String str2 = "name = '" + paramString + "'";
      ContentValues localContentValues2 = new ContentValues();
      localContentValues2.put("main", Integer.valueOf(q.o));
      paramContext.getContentResolver().update(q.j, localContentValues2, str2, null);
    }
  }

  public static void b(Context paramContext, String paramString, long paramLong)
  {
    ContentValues localContentValues = new ContentValues();
    localContentValues.put("other", String.valueOf(paramLong));
    ContentResolver localContentResolver = paramContext.getContentResolver();
    Uri localUri = q.j;
    String[] arrayOfString = new String[1];
    arrayOfString[0] = paramString;
    localContentResolver.update(localUri, localContentValues, "name = ?", arrayOfString);
  }

  public static boolean b(Context paramContext, String paramString1, String paramString2)
  {
    int j;
    if (d.h().i())
      j = 1;
    while (true)
    {
      return j;
      Cursor localCursor;
      if (paramString2 != null)
      {
        ContentResolver localContentResolver = paramContext.getContentResolver();
        Uri localUri = q.j;
        String[] arrayOfString1 = a;
        String[] arrayOfString2 = new String[1];
        arrayOfString2[0] = paramString1;
        localCursor = localContentResolver.query(localUri, arrayOfString1, "name =?", arrayOfString2, null);
        if (localCursor == null);
      }
      try
      {
        if (localCursor.moveToFirst())
        {
          boolean bool = paramString2.equals(localCursor.getString(2));
          j = bool;
          if (localCursor == null)
            continue;
          localCursor.close();
          continue;
        }
        if (localCursor != null)
          localCursor.close();
        j = 0;
      }
      finally
      {
        if (localCursor != null)
          localCursor.close();
      }
    }
  }

  public static void c(Context paramContext, String paramString)
  {
    if ((TextUtils.isEmpty(paramString)) || (paramContext == null));
    while (true)
    {
      return;
      String str = "name = '" + paramString + "'";
      paramContext.getContentResolver().delete(q.j, str, null);
    }
  }

  public static void d(Context paramContext, String paramString)
  {
    if ((TextUtils.isEmpty(paramString)) || (paramContext == null));
    while (true)
    {
      return;
      String str = "name = '" + paramString + "' " + " AND " + "main" + " = " + q.o;
      ContentValues localContentValues = new ContentValues();
      localContentValues.put("main", Integer.valueOf(q.p));
      paramContext.getContentResolver().update(q.j, localContentValues, str, null);
    }
  }

  public static boolean e(Context paramContext, String paramString)
  {
    int j = 0;
    if ((TextUtils.isEmpty(paramString)) || (paramContext == null));
    Cursor localCursor;
    while (true)
    {
      return j;
      String str = "name = '" + paramString + "' ";
      localCursor = paramContext.getContentResolver().query(q.j, a, str, null, null);
      if ((localCursor != null) && (localCursor.moveToFirst()))
        break;
      if (localCursor == null)
        continue;
      localCursor.close();
    }
    int k = localCursor.getInt(7);
    localCursor.close();
    if (k == 0);
    for (int m = 1; ; m = 0)
    {
      j = m;
      break;
    }
  }

  public static boolean f(Context paramContext, String paramString)
  {
    int j;
    if ((paramContext == null) || (TextUtils.isEmpty(paramString)))
      j = 0;
    while (true)
    {
      return j;
      ContentResolver localContentResolver = paramContext.getContentResolver();
      Uri localUri = q.j;
      String[] arrayOfString1 = a;
      String[] arrayOfString2 = new String[1];
      arrayOfString2[0] = paramString;
      Cursor localCursor = localContentResolver.query(localUri, arrayOfString1, "name =?", arrayOfString2, null);
      if (localCursor != null)
      {
        if (localCursor.moveToFirst())
        {
          localCursor.close();
          j = 1;
          continue;
        }
        localCursor.close();
      }
      j = 0;
    }
  }

  public static long g(Context paramContext, String paramString)
  {
    Cursor localCursor;
    if (paramContext != null)
    {
      ContentResolver localContentResolver = paramContext.getContentResolver();
      Uri localUri = q.j;
      String[] arrayOfString1 = a;
      String[] arrayOfString2 = new String[1];
      arrayOfString2[0] = paramString;
      localCursor = localContentResolver.query(localUri, arrayOfString1, "name =?", arrayOfString2, null);
      if (localCursor == null);
    }
    try
    {
      long l1;
      if (localCursor.moveToFirst())
      {
        String str = localCursor.getString(6);
        if (str != null)
        {
          long l2 = Long.parseLong(str);
          l1 = l2;
        }
      }
      while (true)
      {
        return l1;
        localCursor.close();
        l1 = 0L;
      }
    }
    catch (Exception localException)
    {
      while (true)
      {
        localException.printStackTrace();
        localCursor.close();
      }
    }
    finally
    {
      localCursor.close();
    }
    throw localObject;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.c.h
 * JD-Core Version:    0.6.0
 */